﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuDada.Core.Post;
using WuDada.Core.Post.Service;
using WuDada.Core.Post.Domain;
using System.Text;

public partial class team2 : System.Web.UI.Page
{
    private PostFactory m_PostFactory;
    private IPostService m_PostService;

    //醫師陣容 NodeId=9
    private int m_NodeId = 9;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_PostFactory = new PostFactory();
        m_PostService = m_PostFactory.GetPostService();

        if (!IsPostBack)
        {
            FillNews();
        }
    }

    private void FillNews()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", m_NodeId.ToString());
        conditions.Add("Flag", "1");

        //分頁
        AspNetPager1.RecordCount = m_PostService.GetPostCount(conditions);
        int pageIndex = (AspNetPager1.CurrentPageIndex - 1);
        int pageSize = AspNetPager1.PageSize;
        conditions.Add("PageIndex", pageIndex.ToString());
        conditions.Add("PageSize", pageSize.ToString());

        RepeaterTeam.DataSource = m_PostService.GetPostList(conditions);
        RepeaterTeam.DataBind();
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        FillNews();
    }

    protected void RepeaterTeam_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //if (e.Item.ItemIndex != -1)
        //{
        //    Control ctrl = e.Item;
        //    PostVO postVO = (PostVO)e.Item.DataItem;

        //    ////主治項目
        //    StringBuilder sbIndications = new StringBuilder();
        //    if (!string.IsNullOrEmpty(postVO.CustomField2))
        //    {
        //        string[] list = postVO.CustomField2.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        //        foreach (string s in list)
        //        {
        //            sbIndications.AppendFormat("{0}、", s);
        //        }
        //    }

        //    UIHelper.SetLiteralText(ctrl, "ltlIndications", sbIndications.ToString().TrimEnd('、'));
        //}
    }
}